<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<!-- Mirrored from www.wolfssl.com/wolfSSL/Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc.html by HTTrack Website Copier/3.x [XR&CO'2014], Tue, 17 Jan 2017 13:40:25 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=UTF-8" /><!-- /Added by HTTrack -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="Generator" content="iWeb 3.0.4"/>
<meta name="iWeb-Build" content="local-build-20170103"/>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
<meta name="viewport" content="width=770"/>
<title>wolfSSL - Docs | wolfCrypt Manual - Chapter 18.14 (ECC)</title>
<link rel="stylesheet" type="text/css" media="screen,print" href="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc.css"/>
<!--[if lt IE 8]><link rel='stylesheet' type='text/css' media='screen,print' href='Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/Docs-wolfssl-manual-18-14-wolfcrypt-api-eccIE.css'/><![endif]-->
<!--[if gte IE 8]><link rel='stylesheet' type='text/css' media='screen,print' href='Media/IE8.css'/><![endif]-->
<script type="text/javascript" src="Scripts/iWebSite.js"></script>
<script type="text/javascript" src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc.js"></script>
<meta name="description" content="wolfSSL - Docs | wolfCrypt Manual - Chapter 18.14 (ECC)"/><meta name="keywords" content="embedded ssl, ssl library, embedded security, openssl alternative, ssl api, ssl, tls, cyassl, openssl replacement, openssl api, ssl functions, small openssl, smart grid, connected home, ecc, lightweight ssl, suite b, encryption security software, ssl inspection"/><meta name="robots" content="follow,index"/> <script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','../../www.google-analytics.com/analytics.js','ga');ga('create','UA-64826966-1','auto');ga('send','pageview');</script>
 
<script>//<![CDATA[
window.zEmbed||function(e,t){var n,o,d,i,s,a=[],r=document.createElement("iframe");window.zEmbed=function(){a.push(arguments)},window.zE=window.zE||window.zEmbed,r.src="javascript:false",r.title="",r.role="presentation",(r.frameElement||r).style.cssText="display: none",d=document.getElementsByTagName("script"),d=d[d.length-1],d.parentNode.insertBefore(r,d),i=r.contentWindow,s=i.document;try{o=s}catch(c){n=document.domain,r.src='javascript:var d=document.open();d.domain="'+n+'";void(0);',o=s}o.open()._l=function(){var o=this.createElement("script");n&&(this.domain=n),o.id="js-iframe-async",o.src=e,this.t=+new Date,this.zendeskHost=t,this.zEQueue=a,this.body.appendChild(o)},o.write('<body onload="document._l();">'),o.close()}("../../assets.zendesk.com/embeddable_framework/main.js","wolfssl.zendesk.com");
//]]></script>
  </head>
<body style="background: rgb(255, 255, 255); margin: 0pt; " onload="onPageLoad();">
<div style="text-align: center; ">
<div style="margin-bottom: 20px; margin-left: auto; margin-right: auto; margin-top: 20px; overflow: hidden; position: relative; word-wrap: break-word;  background: rgb(255, 255, 255); text-align: left; width: 770px; " id="body_content">
<div style="float: left; margin-left: 0px; position: relative; width: 770px; z-index: 0; " id="nav_layer">
<div style="height: 0px; line-height: 0px; " class="bumper"> </div>
<div style="clear: both; height: 0px; line-height: 0px; " class="spacer"> </div>
</div>
<div style="float: left; height: 0px; line-height: 0px; margin-left: 0px; position: relative; width: 770px; z-index: 10; " id="header_layer">
<div style="height: 0px; line-height: 0px; " class="bumper"> </div>
</div>
<div style="margin-left: 0px; position: relative; width: 770px; z-index: 5; " id="body_layer">
<div style="height: 0px; line-height: 0px; " class="bumper"> </div>
<div id="id1" style="height: 38px; left: 375px; position: absolute; top: 157px; width: 361px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_361_38" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style">wolfSSL Manual</p>
</div>
</div>
</div>
<div id="id2" style="height: 24px; left: 193px; position: absolute; top: 122px; width: 268px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_268_24" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_1"><a class="class1" title="Docs.html" href="Docs.html">Docs</a> <span class="style">-&gt;</span> <span class="style_1">wolfSSL Manual</span></p>
</div>
</div>
</div>
<div style="height: 1px; width: 698px;  height: 1px; left: 37px; position: absolute; top: 220px; width: 698px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 698px; ">
<img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_1.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 698px; "/>
</div>
</div>
<div style="height: 37px; width: 545px;  height: 37px; left: 191px; position: absolute; top: 80px; width: 545px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 545px; ">
<img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_2.png" alt="" style="height: 37px; left: 0px; position: absolute; top: 0px; width: 545px; "/>
</div>
</div>
<div id="id3" style="height: 25px; left: 200px; position: absolute; top: 84px; width: 43px; z-index: 1; " class="style_SkipStroke_1 shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_43_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_2"><a class="class2" title="Home.html" href="Home.html">Home</a></p>
</div>
</div>
</div>
<div id="id4" style="height: 25px; left: 365px; position: absolute; top: 84px; width: 72px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_72_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_3"><a class="class3" title="https://wolfssl.com/wolfSSL/download/downloadForm.php" href="https://wolfssl.com/wolfSSL/download/downloadForm.php">Download</a></p>
</div>
</div>
</div>
<div id="id5" style="height: 25px; left: 439px; position: absolute; top: 84px; width: 59px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_59_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_3"><a class="class4" title="License.html" href="License.html">License</a></p>
</div>
</div>
</div>
<div id="id6" style="height: 25px; left: 499px; position: absolute; top: 84px; width: 44px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_44_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_3"><a class="class5" title="Blog/Blog.html" href="Blog/Blog.html">Blog</a></p>
</div>
</div>
</div>
<div id="id7" style="height: 25px; left: 589px; position: absolute; top: 84px; width: 80px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_80_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_3"><a class="class6" title="Community.html" href="Community.html">Community</a></p>
</div>
</div>
</div>
<div style="height: 36px; width: 1px;  height: 36px; left: 245px; position: absolute; top: 81px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_3.png" alt="" style="height: 36px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div style="height: 37px; width: 1px;  height: 37px; left: 296px; position: absolute; top: 80px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_4.png" alt="" style="height: 37px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div style="height: 36px; width: 1px;  height: 36px; left: 363px; position: absolute; top: 81px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_5.png" alt="" style="height: 36px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div style="height: 36px; width: 1px;  height: 36px; left: 438px; position: absolute; top: 81px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_6.png" alt="" style="height: 36px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div style="height: 37px; width: 1px;  height: 37px; left: 498px; position: absolute; top: 80px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_7.png" alt="" style="height: 37px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div style="height: 37px; width: 1px;  height: 37px; left: 589px; position: absolute; top: 80px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_8.png" alt="" style="height: 37px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div id="id8" style="height: 25px; left: 671px; position: absolute; top: 84px; width: 61px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_61_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_3"><a class="class7" title="Contact.html" href="Contact.html">Contact</a></p>
</div>
</div>
</div>
<div id="id9" style="height: 25px; left: 249px; position: absolute; top: 84px; width: 44px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_44_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_2"><a class="class8" title="About.html" href="About.html">About</a></p>
</div>
</div>
</div>
<div style="height: 36px; width: 1px;  height: 36px; left: 670px; position: absolute; top: 81px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_9.png" alt="" style="height: 36px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div id="id10" style="height: 25px; left: 298px; position: absolute; top: 84px; width: 63px; z-index: 1; " class="style_SkipStroke_1 shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_63_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_3"><a class="class9" title="Products.html" href="Products.html">Products</a></p>
</div>
</div>
</div>
<div id="id11" style="height: 25px; left: 549px; position: absolute; top: 84px; width: 41px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_41_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_2"><a class="class10" title="Docs.html" href="Docs.html">Docs</a></p>
</div>
</div>
</div>
<div style="height: 37px; width: 1px;  height: 37px; left: 545px; position: absolute; top: 80px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_10.png" alt="" style="height: 37px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div id="id12" style="height: 27px; left: 634px; position: absolute; top: 224px; width: 102px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_102_27" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_4"><a class="class11" title="Docs-wolfssl-manual-18-15-wolfcrypt-api-ed25519.html" href="Docs-wolfssl-manual-18-15-wolfcrypt-api-ed25519.html">Next Chapter</a></p>
</div>
</div>
</div>
<div id="id13" style="height: 25px; left: 35px; position: absolute; top: 224px; width: 125px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_125_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_5"><a class="class12" title="Docs-wolfssl-manual-18-13-wolfcrypt-api-dsa.html" href="Docs-wolfssl-manual-18-13-wolfcrypt-api-dsa.html">Previous Chapter</a></p>
</div>
</div>
</div>
<div style="height: 22px; width: 22px;  height: 22px; left: 33px; position: absolute; top: 191px; width: 22px; z-index: 1; " class="tinyText style_SkipStroke_2">
<img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/PDF.png" alt="" style="border: none; height: 22px; width: 22px; "/>
</div>
<div id="id14" style="height: 25px; left: 323px; position: absolute; top: 224px; width: 125px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_125_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_6"><a title="Docs-wolfssl-manual-toc.html" href="Docs-wolfssl-manual-toc.html">Table of Contents</a></p>
</div>
</div>
</div>
<div id="id15" style="height: 14051px; left: 35px; position: absolute; top: 281px; width: 701px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_701_14051" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-top: 0pt; " class="paragraph_style_7">Chapter 18: wolfCrypt API Reference<br/></p>
<p class="paragraph_style_7"><br/></p>
<p class="paragraph_style_8">18.14  ECC<br/></p>
<p class="paragraph_style_8"><br/></p>
<p class="paragraph_style_9">The functions in this section expose ECC functionality to calling applications.<span class="style_2"><br/></span></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_11.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_11"><br/></p>
<p class="paragraph_style_12">wc_ecc_make_key<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_9">#include &lt;wolfssl/wolfcrypt/ecc.h&gt;<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_9">int wc_ecc_make_key(RNG* rng, int keysize, ecc_key* key);<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_9">This function generates a new ecc_key and stores it in key. <br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_9"><span class="style_3">ECC_BAD_ARG_E</span>: Returned if rng or key evaluate to NULL<br/></p>
<p class="paragraph_style_9"><span class="style_3">BAD_FUNC_ARG</span>: Returned if the specified key size is not in the correct range of supported keys<br/></p>
<p class="paragraph_style_9"><span class="style_3">MEMORY_E</span>: Returned if there is an error allocating memory while computing the ecc key<br/></p>
<p class="paragraph_style_9"><span class="style_3">MP_INIT_E</span>, <span class="style_3">MP_READ_E</span>, <span class="style_3">MP_CMP_E</span>, <span class="style_3">MP_INVMOD_E</span>, <span class="style_3">MP_EXPTMOD_E</span>, <span class="style_3">MP_MOD_E</span>, <span class="style_3">MP_MUL_E</span>, <span class="style_3">MP_ADD_E</span>, <span class="style_3">MP_MULMOD_E</span>, <span class="style_3">MP_TO_E</span>, and <span class="style_3">MP_MEM</span> may be returned if there is an error while computing the ecc key<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_9"><span class="style_3">rng</span> - pointer to an initialized RNG object with which to generate the key<br/></p>
<p class="paragraph_style_9"><span class="style_3">keysize</span> - desired length for the ecc_key<br/></p>
<p class="paragraph_style_9"><span class="style_3">key</span> - pointer to the ecc_key for which to generate a key<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_14">ecc_key key;<br/></p>
<p class="paragraph_style_14">wc_ecc_init(&amp;key);<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">RNG rng;<br/></p>
<p class="paragraph_style_14">wc_InitRng(&amp;rng);<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">wc_ecc_make_key(&amp;rng, 32, &amp;key); // initialize 32 byte ecc key<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_9">wc_ecc_init, wc_ecc_shared_secret<br/></p>
<p class="paragraph_style_9"><br/></p>
<div class="paragraph paragraph_style_9"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_12.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_12"><br/></p>
<p class="paragraph_style_12">wc_ecc_shared_secret<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_9">#include &lt;wolfssl/wolfcrypt/ecc.h&gt;<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_9">int wc_ecc_shared_secret(ecc_key* private_key, ecc_key* public_key, byte* out, <br/></p>
<p class="paragraph_style_9">word32* outlen);<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_9">This function generates a new secret key using a local private key and a received public key. It stores this shared secret key in the buffer out and updates outlen to hold the number of bytes written to the output buffer.<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_9"><span class="style_3">0</span>: Returned upon successfully generating a shared secret key<br/></p>
<p class="paragraph_style_9"><span class="style_3">BAD_FUNC_ARG</span>: Returned if any of the input parameters evaluate to NULL<br/></p>
<p class="paragraph_style_9"><span class="style_3">ECC_BAD_ARG_E</span>: Returned if the type of the private key given as argument, private_key, is not ECC_PRIVATEKEY, or if the public and private key types (given by ecc-&gt;dp) are not equivalent<br/></p>
<p class="paragraph_style_9"><span class="style_3">MEMORY_E</span>: Returned if there is an error generating a new ecc point<br/></p>
<p class="paragraph_style_9"><span class="style_3">BUFFER_E</span>: Returned if the generated shared secret key is too long to store in the provided buffer<br/></p>
<p class="paragraph_style_9"><span class="style_3">MP_INIT_E</span>, <span class="style_3">MP_READ_E</span>, <span class="style_3">MP_CMP_E</span>, <span class="style_3">MP_INVMOD_E</span>, <span class="style_3">MP_EXPTMOD_E</span>, <span class="style_3">MP_MOD_E</span>, <span class="style_3">MP_MUL_E</span>, <span class="style_3">MP_ADD_E</span>, <span class="style_3">MP_MULMOD_E</span>, <span class="style_3">MP_TO_E</span>, and <span class="style_3">MP_MEM</span> may be returned if there is an error while computing the shared key<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_9"><span class="style_3">private_key</span> - pointer to the ecc_key structure containing the local private key<br/></p>
<p class="paragraph_style_9"><span class="style_3">public_key</span> - pointer to the ecc_key structure containing the received public key<br/></p>
<p class="paragraph_style_9"><span class="style_3">out</span> - pointer to an output buffer in which to store the generated shared secret key<br/></p>
<p class="paragraph_style_9"><span class="style_3">outlen</span> - pointer to the word32 object containing the length of the output buffer. Will be overwritten with the length written to the output buffer upon successfully generating a shared secret key<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_14">ecc_key priv, pub;<br/></p>
<p class="paragraph_style_14">RNG rng;<br/></p>
<p class="paragraph_style_14">byte secret[1024]; // can hold 1024 byte shared secret key<br/></p>
<p class="paragraph_style_14">word32 secretSz = sizeof(secret);<br/></p>
<p class="paragraph_style_14">int ret;<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">wc_InitRng(&amp;rng); // initialize rng<br/></p>
<p class="paragraph_style_14">wc_ecc_init(&amp;priv); // initialize key<br/></p>
<p class="paragraph_style_14">wc_ecc_make_key(&amp;rng, 32, &amp;priv); // make public/private key pair<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">// receive public key, and initialise into pub<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">ret = wc_ecc_shared_secret(&amp;priv, &amp;pub, secret, &amp;secretSz); // generate secret key<br/></p>
<p class="paragraph_style_14">if ( ret != 0 ) {<br/></p>
<p class="paragraph_style_14">// error generating shared secret key<br/></p>
<p class="paragraph_style_14">}<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_9">wc_ecc_init, wc_ecc_make_key<br/></p>
<p class="paragraph_style_9"><br/></p>
<div class="paragraph paragraph_style_9"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_13.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_12"><br/></p>
<p class="paragraph_style_12">wc_ecc_sign_hash<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_9">#include &lt;wolfssl/wolfcrypt/ecc.h&gt;<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_9">int wc_ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen, RNG* rng, <br/></p>
<p class="paragraph_style_9">ecc_key* key)<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_9">This function signs a message digest using an ecc_key object to guarantee authenticity. <br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_9"><span class="style_3">0</span>: Returned upon successfully generating a signature for the message digest<br/></p>
<p class="paragraph_style_9"><span class="style_3">BAD_FUNC_ARG</span>: Returned if any of the input parameters evaluate to NULL, or if the output buffer is too small to store the generated signature<br/></p>
<p class="paragraph_style_9"><span class="style_3">ECC_BAD_ARG_E</span>: Returned if the input key is not a private key, or if the ECC OID is invalid<br/></p>
<p class="paragraph_style_9"><span class="style_3">RNG_FAILURE_E</span>: Returned if the rng cannot successfully generate a satisfactory key<br/></p>
<p class="paragraph_style_9"><span class="style_3">MP_INIT_E</span>, <span class="style_3">MP_READ_E</span>, <span class="style_3">MP_CMP_E</span>, <span class="style_3">MP_INVMOD_E</span>, <span class="style_3">MP_EXPTMOD_E</span>, <span class="style_3">MP_MOD_E</span>, <span class="style_3">MP_MUL_E</span>, <span class="style_3">MP_ADD_E</span>, <span class="style_3">MP_MULMOD_E</span>, <span class="style_3">MP_TO_E</span>, and <span class="style_3">MP_MEM</span> may be returned if there is an error while computing the message signature<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_9"><span class="style_3">in</span> - pointer to the buffer containing the message hash to sign<br/></p>
<p class="paragraph_style_9"><span class="style_3">inlen</span> - length of the message hash to sign<br/></p>
<p class="paragraph_style_9"><span class="style_3">out</span> - buffer in which to store the generated signature<br/></p>
<p class="paragraph_style_9"><span class="style_3">outlen</span> - max length of the output buffer. Will store the bytes written to out upon successfully generating a message signature<br/></p>
<p class="paragraph_style_9"><span class="style_3">key</span> - pointer to a private ECC key with which to generate the signature<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_14">ecc_key key;<br/></p>
<p class="paragraph_style_14">RNG rng;<br/></p>
<p class="paragraph_style_14">int ret, sigSz;<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">byte sig[512]; // will hold generated signature<br/></p>
<p class="paragraph_style_14">sigSz = sizeof(sig);<br/></p>
<p class="paragraph_style_14">byte digest[] = { /* initialize with message hash */ };<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">wc_InitRng(&amp;rng); // initialize rng<br/></p>
<p class="paragraph_style_14">wc_ecc_init(&amp;key); // initialize key<br/></p>
<p class="paragraph_style_14">wc_ecc_make_key(&amp;rng, 32, &amp;key); // make public/private key pair<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">ret = wc_ecc_sign_hash(digest, sizeof(digest), sig, &amp;sigSz, &amp;key);<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">if ( ret != 0 ) {<br/></p>
<p class="paragraph_style_14">// error generating message signature<br/></p>
<p class="paragraph_style_14">}<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_9">wc_ecc_verify_hash<br/></p>
<p class="paragraph_style_9"><br/></p>
<div class="paragraph paragraph_style_9"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_14.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_12"><br/></p>
<p class="paragraph_style_12">wc_ecc_verify_hash<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_9">#include &lt;wolfssl/wolfcrypt/ecc.h&gt;<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_9">int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash, word32 hashlen,<br/></p>
<p class="paragraph_style_9"> int* stat, ecc_key* key); <br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_9">This function verifies the ECC signature of a hash to ensure authenticity. It returns the answer through stat, with 1 corresponding to a valid signature, and 0 corresponding to an invalid signature.<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_9"><span class="style_3">0</span>: Returned upon successfully performing the signature verification. Note: This does not mean that the signature is verified. The authenticity information is stored instead in stat<br/></p>
<p class="paragraph_style_9"><span class="style_3">BAD_FUNC_ARG</span>: Returned any of the input parameters evaluate to NULL<br/></p>
<p class="paragraph_style_9"><span class="style_3">MEMORY_E</span>: Returned if there is an error allocating memory<span class="style_3"><br/></span></p>
<p class="paragraph_style_9"><span class="style_3">MP_INIT_E</span>, <span class="style_3">MP_READ_E</span>, <span class="style_3">MP_CMP_E</span>, <span class="style_3">MP_INVMOD_E</span>, <span class="style_3">MP_EXPTMOD_E</span>, <span class="style_3">MP_MOD_E</span>, <span class="style_3">MP_MUL_E</span>, <span class="style_3">MP_ADD_E</span>, <span class="style_3">MP_MULMOD_E</span>, <span class="style_3">MP_TO_E</span>, and <span class="style_3">MP_MEM</span> may be returned if there is an error while computing the message signature<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_9"><span class="style_3">sig</span> - pointer to the buffer containing the signature to verify<br/></p>
<p class="paragraph_style_9"><span class="style_3">siglen</span> - length of the signature to verify<br/></p>
<p class="paragraph_style_9"><span class="style_3">hash</span> - pointer to the buffer containing the hash of the message verified<br/></p>
<p class="paragraph_style_9"><span class="style_3">hashlen</span> - length of the hash of the message verified<br/></p>
<p class="paragraph_style_9"><span class="style_3">stat</span> - pointer to the result of the verification. 1 indicates the message was successfully verified<br/></p>
<p class="paragraph_style_9"><span class="style_3">key</span> - pointer to a public ECC key with which to verify the signature<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_14">ecc_key key;<br/></p>
<p class="paragraph_style_14">int ret, verified = 0;<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">byte sig[1024] { /* initialize with received signature */ };<br/></p>
<p class="paragraph_style_14">byte digest[] = { /* initialize with message hash */ };<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">// initialize key with received public key<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">ret = wc_ecc_verify_hash(sig, sizeof(sig), digest,sizeof(digest), &amp;verified, &amp;key);<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">if ( ret != 0 ) {<br/></p>
<p class="paragraph_style_14">// error performing verification<br/></p>
<p class="paragraph_style_14">} else if ( verified == 0 ) {<br/></p>
<p class="paragraph_style_14">// the signature is invalid<br/></p>
<p class="paragraph_style_14">}<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_9">wc_ecc_sign_hash<br/></p>
<p class="paragraph_style_9"><br/></p>
<div class="paragraph paragraph_style_9"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_15.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_12"><br/></p>
<p class="paragraph_style_12">wc_ecc_init<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_9">#include &lt;wolfssl/wolfcrypt/ecc.h&gt;<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_9">int wc_ecc_init(ecc_key* key);<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_9">This function initializes an ecc_key object for future use with message verification or key negotiation. <br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_9"><span class="style_3">0</span>: Returned upon successfully initializing the ecc_key object<br/></p>
<p class="paragraph_style_9"><span class="style_3">MEMORY</span>_E: Returned if there is an error allocating memory<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_9"><span class="style_3">key</span> - pointer to the ecc_key object to initialize<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_14">ecc_key key;<br/></p>
<p class="paragraph_style_14">wc_ecc_init(&amp;key);<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_9">wc_ecc_make_key, wc_ecc_free<br/></p>
<p class="paragraph_style_9"><br/></p>
<div class="paragraph paragraph_style_9"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_16.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_12"><br/></p>
<p class="paragraph_style_12">wc_ecc_free<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_9">#include &lt;wolfssl/wolfcrypt/ecc.h&gt;<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_9">void wc_ecc_free(ecc_key* key)<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_9">This function frees an ecc_key object after it has been used.<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_9">No return value for this function. <br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_9"><span class="style_3">key</span> - pointer to the ecc_key object to free<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_14">ecc_key key;<br/></p>
<p class="paragraph_style_14">// initialize key and perform secure exchanges<br/></p>
<p class="paragraph_style_14">...<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">wc_ecc_free(&amp;key);<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_9">wc_ecc_init<br/></p>
<p class="paragraph_style_9"><br/></p>
<div class="paragraph paragraph_style_9"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_17.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_12"><br/></p>
<p class="paragraph_style_12">wc_ecc_fp_free<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_9">#include &lt;wolfssl/wolfcrypt/ecc.h&gt;<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_9">void wc_ecc_fp_free(void);<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_9">This function frees the fixed-point cache, which can be used with ecc to speed up computation times. To use this functionality, FP_ECC (fixed-point ecc), should be defined.<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_9">No return value for this function.<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_9">No parameters for this function.<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_14">ecc_key key;<br/></p>
<p class="paragraph_style_14">// initialize key and perform secure exchanges<br/></p>
<p class="paragraph_style_14">...<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">wc_ecc_fp_free();<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_9">wc_ecc_free<br/></p>
<p class="paragraph_style_9"><br/></p>
<div class="paragraph paragraph_style_9"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_18.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_12"><br/></p>
<p class="paragraph_style_12">wc_ecc_export_x963<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_9">#include &lt;wolfssl/wolfcrypt/ecc.h&gt;<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_9">int wc_ecc_export_x963(ecc_key* key, byte* out, word32* outLen);<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_9">This function exports the ECC key from the ecc_key structure, storing the result in out. The key will be stored in ANSI X9.63 format. It stores the bytes written to the output buffer in outLen.<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_9"><span class="style_3">0</span>: Returned on successfully exporting the ecc_key<br/></p>
<p class="paragraph_style_9"><span class="style_3">LENGTH_ONLY_E</span>: Returned if the output buffer evaluates to NULL, but the other two input parameters are valid. Indicates that the function is only returning the length required to store the key<br/></p>
<p class="paragraph_style_9"><span class="style_3">ECC_BAD_ARG_E</span>: Returned if any of the input parameters are NULL, or the key is unsupported (has an invalid index)<br/></p>
<p class="paragraph_style_9"><span class="style_3">BUFFER_E</span>: Returned if the output buffer is too small to store the ecc key. If the output buffer is too small, the size needed will be returned in outLen<br/></p>
<p class="paragraph_style_9"><span class="style_3">MEMORY_E</span>: Returned if there is an error allocating memory with XMALLOC<br/></p>
<p class="paragraph_style_9"><span class="style_3">MP_INIT_E</span>, <span class="style_3">MP_READ_E</span>, <span class="style_3">MP_CMP_E</span>, <span class="style_3">MP_INVMOD_E</span>, <span class="style_3">MP_EXPTMOD_E</span>, <span class="style_3">MP_MOD_E</span>, <span class="style_3">MP_MUL_E</span>, <span class="style_3">MP_ADD_E</span>, <span class="style_3">MP_MULMOD_E</span>, <span class="style_3">MP_TO_E</span>, and <span class="style_3">MP_MEM</span> may be returned if there is an error processing the ecc_key<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_9"><span class="style_3">key</span> - pointer to the ecc_key object to export<br/></p>
<p class="paragraph_style_9"><span class="style_3">out</span> - pointer to the buffer in which to store the ANSI X9.63 formatted key<br/></p>
<p class="paragraph_style_9"><span class="style_3">outLen</span> - size of the output buffer. On successfully storing the key, will hold the bytes written to the output buffer<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_14">int ret;<br/></p>
<p class="paragraph_style_14">byte buff[1024];<br/></p>
<p class="paragraph_style_14">word32 buffSz = sizeof(buff);<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">ecc_key key;<br/></p>
<p class="paragraph_style_14">// initialize key, make key<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">ret = wc_ecc_export_x963(&amp;key, buff, &amp;buffSz);<br/></p>
<p class="paragraph_style_14">if ( ret != 0) {<br/></p>
<p class="paragraph_style_14">// error exporting key<br/></p>
<p class="paragraph_style_14">}<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_9">wc_ecc_export_x963_ex, wc_ecc_import_x963<br/></p>
<p class="paragraph_style_9"><br/></p>
<div class="paragraph paragraph_style_9"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_19.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_12"><br/></p>
<p class="paragraph_style_12">wc_ecc_export_x963_ex<br/></p>
<p class="paragraph_style_15"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_9">#include &lt;wolfssl/wolfcrypt/ecc.h&gt;<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_9">int wc_ecc_export_x963_ex(ecc_key* key, byte* out, word32* outLen, int compressed);<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_9">This function exports the ECC key from the ecc_key structure, storing the result in out. The key will be stored in ANSI X9.63 format. It stores the bytes written to the output buffer in outLen. This function allows the additional option of compressing the certificate through the compressed parameter. When this parameter is true, the key will be stored in ANSI X9.63 compressed format.<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_9"><span class="style_3">0</span>: Returned on successfully exporting the ecc_key<br/></p>
<p class="paragraph_style_9"><span class="style_3">NOT_COMPILED_IN</span>: Returned if the HAVE_COMP_KEY was not enabled at compile time, but the key was requested in compressed format<br/></p>
<p class="paragraph_style_9"><span class="style_3">LENGTH_ONLY_E</span>: Returned if the output buffer evaluates to NULL, but the other two input parameters are valid. Indicates that the function is only returning the length required to store the key<br/></p>
<p class="paragraph_style_9"><span class="style_3">ECC_BAD_ARG_E</span>: Returned if any of the input parameters are NULL, or the key is unsupported (has an invalid index)<br/></p>
<p class="paragraph_style_9"><span class="style_3">BUFFER_E</span>: Returned if the output buffer is too small to store the ecc key. If the output buffer is too small, the size needed will be returned in outLen<br/></p>
<p class="paragraph_style_9"><span class="style_3">MEMORY_E</span>: Returned if there is an error allocating memory with XMALLOC<br/></p>
<p class="paragraph_style_9"><span class="style_3">MP_INIT_E</span>, <span class="style_3">MP_READ_E</span>, <span class="style_3">MP_CMP_E</span>, <span class="style_3">MP_INVMOD_E</span>, <span class="style_3">MP_EXPTMOD_E</span>, <span class="style_3">MP_MOD_E</span>, <span class="style_3">MP_MUL_E</span>, <span class="style_3">MP_ADD_E</span>, <span class="style_3">MP_MULMOD_E</span>, <span class="style_3">MP_TO_E</span>, and <span class="style_3">MP_MEM</span> may be returned if there is an error processing the ecc_key <br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_9"><span class="style_3">key</span> - pointer to the ecc_key object to export<br/></p>
<p class="paragraph_style_9"><span class="style_3">out</span> - pointer to the buffer in which to store the ANSI X9.63 formatted key<br/></p>
<p class="paragraph_style_9"><span class="style_3">outLen</span> - size of the output buffer. On successfully storing the key, will hold the bytes written to the output buffer<br/></p>
<p class="paragraph_style_9"><span class="style_3">compressed</span> - indicator of whether to store the key in compressed format. 1==compressed, 0==uncompressed<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_14">int ret;<br/></p>
<p class="paragraph_style_14">byte buff[1024];<br/></p>
<p class="paragraph_style_14">word32 buffSz = sizeof(buff);<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">ecc_key key;<br/></p>
<p class="paragraph_style_14">// initialize key, make key<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">ret = wc_ecc_export_x963_ex(&amp;key, buff, &amp;buffSz, 1);<br/></p>
<p class="paragraph_style_14">if ( ret != 0) {<br/></p>
<p class="paragraph_style_14">// error exporting key<br/></p>
<p class="paragraph_style_14">}<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_9">wc_ecc_export_x963, wc_ecc_import_x963<br/></p>
<p class="paragraph_style_9"><br/></p>
<div class="paragraph paragraph_style_9"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_20.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_12"><br/></p>
<p class="paragraph_style_12">wc_ecc_import_x963<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_9">#include &lt;wolfssl/wolfcrypt/ecc.h&gt;<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_9">int wc_ecc_import_x963(const byte* in, word32 inLen, ecc_key* key);<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_9">This function imports a public ECC key from a buffer containing the key stored in ANSI X9.63 format. This function will handle both compressed and uncompressed keys, as long as compressed keys are enabled at compile time through the HAVE_COMP_KEY option.<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_9"><span class="style_3">0</span>: Returned on successfully importing the ecc_key<br/></p>
<p class="paragraph_style_9"><span class="style_3">NOT_COMPILED_IN</span>: Returned if the HAVE_COMP_KEY was not enabled at compile time, but the key is stored in compressed format<br/></p>
<p class="paragraph_style_9"><span class="style_3">ECC_BAD_ARG_E</span>: Returned if in or key evaluate to NULL, or the inLen is even (according to the x9.63 standard, the key must be odd)<br/></p>
<p class="paragraph_style_9"><span class="style_3">MEMORY_E</span>: Returned if there is an error allocating memory<br/></p>
<p class="paragraph_style_9"><span class="style_3">ASN_PARSE_E</span>: Returned if there is an error parsing the ECC key; may indicate that the ECC key is not stored in valid ANSI X9.63 format<br/></p>
<p class="paragraph_style_9"><span class="style_3">IS_POINT_E</span>: Returned if the public key exported is not a point on the ECC curve<br/></p>
<p class="paragraph_style_9"><span class="style_3">MP_INIT_E</span>, <span class="style_3">MP_READ_E</span>, <span class="style_3">MP_CMP_E</span>, <span class="style_3">MP_INVMOD_E</span>, <span class="style_3">MP_EXPTMOD_E</span>, <span class="style_3">MP_MOD_E</span>, <span class="style_3">MP_MUL_E</span>, <span class="style_3">MP_ADD_E</span>, <span class="style_3">MP_MULMOD_E</span>, <span class="style_3">MP_TO_E</span>, and <span class="style_3">MP_MEM</span> may be returned if there is an error processing the ecc_key<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_9"><span class="style_3">in</span> - pointer to the buffer containing the ANSI x9.63 formatted ECC key<br/></p>
<p class="paragraph_style_9"><span class="style_3">inLen</span> - length of the input buffer<br/></p>
<p class="paragraph_style_9"><span class="style_3">key</span> - pointer to the ecc_key object in which to store the imported key<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_14">int ret;<br/></p>
<p class="paragraph_style_14">byte buff[] = { /* initialize with ANSI X9.63 formatted key */ };<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">ecc_key pubKey;<br/></p>
<p class="paragraph_style_14">wc_ecc_init_key(&amp;pubKey);<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">ret = wc_ecc_import_x963(buff, sizeof(buff), &amp;pubKey);<br/></p>
<p class="paragraph_style_14">if ( ret != 0) {<br/></p>
<p class="paragraph_style_14">// error importing key<br/></p>
<p class="paragraph_style_14">}<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_9">wc_ecc_export_x963, wc_ecc_import_private_key<br/></p>
<p class="paragraph_style_9"><br/></p>
<div class="paragraph paragraph_style_9"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_21.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_12"><br/></p>
<p class="paragraph_style_12">wc_ecc_import_private_key<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_9">#include &lt;wolfssl/wolfcrypt/ecc.h&gt;<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_9">int wc_ecc_import_private_key(const byte* priv, word32 privSz, const byte* pub, <br/></p>
<p class="paragraph_style_9">word32 pubSz, ecc_key* key)<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_9">This function imports a public/private ECC key pair from a buffer containing the raw private key, and a second buffer containing the ANSI X9.63 formatted public key. This function will handle both compressed and uncompressed keys, as long as compressed keys are enabled at compile time through the HAVE_COMP_KEY option.<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_9"><span class="style_3">0</span>: Returned on successfully importing the ecc_key<br/></p>
<p class="paragraph_style_9"><span class="style_3">NOT_COMPILED_IN</span>: Returned if the HAVE_COMP_KEY was not enabled at compile time, but the key is stored in compressed format<br/></p>
<p class="paragraph_style_9"><span class="style_3">ECC_BAD_ARG_E</span>: Returned if in or key evaluate to NULL, or the inLen is even (according to the x9.63 standard, the key must be odd)<br/></p>
<p class="paragraph_style_9"><span class="style_3">MEMORY_E</span>: Returned if there is an error allocating memory<br/></p>
<p class="paragraph_style_9"><span class="style_3">ASN_PARSE_E</span>: Returned if there is an error parsing the ECC key; may indicate that the ECC key is not stored in valid ANSI X9.63 format<br/></p>
<p class="paragraph_style_9"><span class="style_3">IS_POINT_E</span>: Returned if the public key exported is not a point on the ECC curve<br/></p>
<p class="paragraph_style_9"><span class="style_3">MP_INIT_E</span>, <span class="style_3">MP_READ_E</span>, <span class="style_3">MP_CMP_E</span>, <span class="style_3">MP_INVMOD_E</span>, <span class="style_3">MP_EXPTMOD_E</span>, <span class="style_3">MP_MOD_E</span>, <span class="style_3">MP_MUL_E</span>, <span class="style_3">MP_ADD_E</span>, <span class="style_3">MP_MULMOD_E</span>, <span class="style_3">MP_TO_E</span>, and <span class="style_3">MP_MEM</span> may be returned if there is an error processing the ecc_key<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_9"><span class="style_3">priv</span> - pointer to the buffer containing the raw private key<br/></p>
<p class="paragraph_style_9"><span class="style_3">privSz</span> - size of the private key buffer<br/></p>
<p class="paragraph_style_9"><span class="style_3">pub</span> - pointer to the buffer containing the ANSI x9.63 formatted ECC public key<br/></p>
<p class="paragraph_style_9"><span class="style_3">pubSz</span> - length of the public key input buffer<br/></p>
<p class="paragraph_style_9"><span class="style_3">key</span> - pointer to the ecc_key object in which to store the imported private/public key pair<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_14">int ret;<br/></p>
<p class="paragraph_style_14">byte pub[] = { /* initialize with ANSI X9.63 formatted key */ };<br/></p>
<p class="paragraph_style_14">byte priv[] = { /* initialize with the raw private key*/ };<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">ecc_key key;<br/></p>
<p class="paragraph_style_14">wc_ecc_init_key(&amp;key);<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">ret = wc_ecc_import_private_key(priv, sizeof(priv), pub, sizeof(pub), &amp;key);<br/></p>
<p class="paragraph_style_14">if ( ret != 0) {<br/></p>
<p class="paragraph_style_14">// error importing key<br/></p>
<p class="paragraph_style_14">}<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_9">wc_ecc_export_x963, wc_ecc_import_private_key<br/></p>
<p class="paragraph_style_9"><br/></p>
<div class="paragraph paragraph_style_9"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_22.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_12"><br/></p>
<p class="paragraph_style_12">wc_ecc_rs_to_sig<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_9">#include &lt;wolfssl/wolfcrypt/ecc.h&gt;<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_9">int wc_ecc_rs_to_sig(const char* r, const char* s, byte* out, word32* outlen)<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_9">This function converts the R and S portions of an ECC signature into a DER-encoded ECDSA signature. This function also stores the length written to the output buffer, out, in outlen. <br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_9"><span class="style_3">0</span>: Returned on successfully converting the signature<br/></p>
<p class="paragraph_style_9"><span class="style_3">ECC_BAD_ARG_E</span>: Returned if any of the input parameters evaluate to NULL, or if the input buffer is not large enough to hold the DER-encoded ECDSA signature<br/></p>
<p class="paragraph_style_9"><span class="style_3">MP_INIT_E</span>, <span class="style_3">MP_READ_E</span>, <span class="style_3">MP_CMP_E</span>, <span class="style_3">MP_INVMOD_E</span>, <span class="style_3">MP_EXPTMOD_E</span>, <span class="style_3">MP_MOD_E,</span> <span class="style_3">MP_MUL_E</span>, <span class="style_3">MP_ADD_E</span>, <span class="style_3">MP_MULMOD_E</span>, <span class="style_3">MP_TO_E</span>, and <span class="style_3">MP_MEM</span> may be returned if there is an error processing the ecc_key<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_9"><span class="style_3">r </span>- pointer to the buffer containing the R portion of the signature as a string<br/></p>
<p class="paragraph_style_9"><span class="style_3">s</span> - pointer to the buffer containing the S portion of the signature as a string<br/></p>
<p class="paragraph_style_9"><span class="style_3">out</span> - pointer to the buffer in which to store the DER-encoded ECDSA signature<br/></p>
<p class="paragraph_style_9"><span class="style_3">outlen</span> - length of the output buffer available. Will store the bytes written to the buffer after successfully converting the signature to ECDSA format<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_14">int ret;<br/></p>
<p class="paragraph_style_14">ecc_key key;<br/></p>
<p class="paragraph_style_14">// initialize key, generate R and S<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">char r[] = { /* initialize with R */ };<br/></p>
<p class="paragraph_style_14">char s[] = { /* initialize with S */ };<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">byte sig[wc_ecc_sig_size(key)]; <br/></p>
<p class="paragraph_style_14">// signature size will be 2 * ECC key size + ~10 bytes for ASN.1 overhead<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">word32 sigSz = sizeof(sig);<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">ret = wc_ecc_rs_to_sig(r, s, sig, &amp;sigSz);<br/></p>
<p class="paragraph_style_14">if ( ret != 0) {<br/></p>
<p class="paragraph_style_14">// error converting parameters to signature<br/></p>
<p class="paragraph_style_14">}<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_9">wc_ecc_sign_hash, wc_ecc_sig_size<br/></p>
<p class="paragraph_style_9"><br/></p>
<div class="paragraph paragraph_style_9"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_23.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_12"><br/></p>
<p class="paragraph_style_12">wc_ecc_import_raw<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_9">#include &lt;wolfssl/wolfcrypt/ecc.h&gt;<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_9">int wc_ecc_import_raw(ecc_key* key, const char* qx, const char* qy, const char* d,<br/></p>
<p class="paragraph_style_9">const char* curveName);<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_9">This function fills an ecc_key structure with the raw components of an ECC signature. <br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_9"><span class="style_3">0</span>: Returned upon successfully importing into the ecc_key structure<br/></p>
<p class="paragraph_style_9"><span class="style_3">ECC_BAD_ARG_E</span>: Returned if any of the input values evaluate to NULL<br/></p>
<p class="paragraph_style_9"><span class="style_3">MEMORY_E</span>: Returned if there is an error initializing space to store the parameters of the ecc_key<br/></p>
<p class="paragraph_style_9"><span class="style_3">ASN_PARSE_E</span>: Returned if the input curveName is not defined in ecc_sets<br/></p>
<p class="paragraph_style_9"><span class="style_3">MP_INIT_E</span>, <span class="style_3">MP_READ_E</span>, <span class="style_3">MP_CMP_E</span>, <span class="style_3">MP_INVMOD_E</span>, <span class="style_3">MP_EXPTMOD_E</span>, <span class="style_3">MP_MOD_E</span>, <span class="style_3">MP_MUL_E</span>, <span class="style_3">MP_ADD_E</span>, <span class="style_3">MP_MULMOD_E</span>, <span class="style_3">MP_TO_E</span>, and <span class="style_3">MP_MEM</span> may be returned if there is an error processing the input parameters<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_9"><span class="style_3">key</span> - pointer to an ecc_key structure to fill<br/></p>
<p class="paragraph_style_9"><span class="style_3">qx</span> - pointer to a buffer containing the x component of the base point as an ASCII hex string<br/></p>
<p class="paragraph_style_9"><span class="style_3">qy</span> - pointer to a buffer containing the y component of the base point as an ASCII hex string<br/></p>
<p class="paragraph_style_9"><span class="style_3">d</span> - pointer to a buffer containing the private key as an ASCII hex string<br/></p>
<p class="paragraph_style_9"><span class="style_3">curveName</span> - pointer to a string containing the ECC curve name, as found in ecc_sets<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_14">int ret;<br/></p>
<p class="paragraph_style_14">ecc_key key;<br/></p>
<p class="paragraph_style_14">wc_ecc_init(&amp;key);<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">char qx[] = { /* initialize with x component of base point */ };<br/></p>
<p class="paragraph_style_14">char qy[] = { /* initialize with y component of base point */ };<br/></p>
<p class="paragraph_style_14">char d[]  = { /* initialize with private key */ };<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">ret = wc_ecc_import_raw(&amp;key,qx, qy, d, &quot;ECC-256&quot;);<br/></p>
<p class="paragraph_style_14">if ( ret != 0) {<br/></p>
<p class="paragraph_style_14">// error initializing key with given inputs<br/></p>
<p class="paragraph_style_14">}<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_9">wc_ecc_import_private_key<br/></p>
<p class="paragraph_style_9"><br/></p>
<div class="paragraph paragraph_style_9"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_24.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_12"><br/></p>
<p class="paragraph_style_12">wc_ecc_export_private_only<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_9">#include &lt;wolfssl/wolfcrypt/ecc.h&gt;<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_9">int wc_ecc_export_private_only(ecc_key* key, byte* out, word32* outLen);<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_9">This function exports only the private key from an ecc_key structure. It stores the private key in the buffer out, and sets the bytes written to this buffer in outLen.<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_9"><span class="style_3">0</span>: Returned upon successfully exporting the private key<br/></p>
<p class="paragraph_style_9"><span class="style_3">ECC_BAD_ARG_E</span>: Returned if any of the input values evaluate to NULL, or the key's index is invalid<br/></p>
<p class="paragraph_style_9"><span class="style_3">BUFFER_E</span>: Returned if the buffer provided is not large enough to store the private key<br/></p>
<p class="paragraph_style_9"><span class="style_3">MP_INIT_E</span>, <span class="style_3">MP_READ_E</span>, <span class="style_3">MP_CMP_E</span>, <span class="style_3">MP_INVMOD_E</span>, <span class="style_3">MP_EXPTMOD_E</span>, <span class="style_3">MP_MOD_E</span>, <span class="style_3">MP_MUL_E</span>, <span class="style_3">MP_ADD_E</span>, <span class="style_3">MP_MULMOD_E</span>, <span class="style_3">MP_TO_E</span>, and <span class="style_3">MP_MEM</span> may be returned if there is an error storing the private key in the given buffer<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_9"><span class="style_3">key</span> - pointer to an ecc_key structure from which to export the private key<br/></p>
<p class="paragraph_style_9"><span class="style_3">out</span> - pointer to the buffer in which to store the private key<br/></p>
<p class="paragraph_style_9"><span class="style_3">outLen</span> - pointer to a word32 object with the size available in out. Set with the number of bytes written to out after successfully exporting the private key<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_14">int ret;<br/></p>
<p class="paragraph_style_14">ecc_key key;<br/></p>
<p class="paragraph_style_14">// initialize key, make key<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">char priv[ECC_KEY_SIZE];<br/></p>
<p class="paragraph_style_14">word32 privSz = sizeof(priv);<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">ret = wc_ecc_export_private_only(&amp;key, priv, &amp;privSz);<br/></p>
<p class="paragraph_style_14">if ( ret != 0) {<br/></p>
<p class="paragraph_style_14">// error exporting private key<br/></p>
<p class="paragraph_style_14">}<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_9">wc_ecc_import_private_key<br/></p>
<p class="paragraph_style_9"><br/></p>
<div class="paragraph paragraph_style_9"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_25.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_12"><br/></p>
<p class="paragraph_style_12">wc_ecc_size<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_9">#include &lt;wolfssl/wolfcrypt/ecc.h&gt;<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_9">int wc_ecc_size(ecc_key* key);<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_9">This function returns the key size of an ecc_key structure in octets.<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_9">Given a valid key, returns the key <span class="style_3">size</span> in octets<br/></p>
<p class="paragraph_style_9"><span class="style_3">0</span>: Returned if the given key is NULL<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_9"><span class="style_3">key</span> - pointer to an ecc_key structure for which to get the key size<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_14">int keySz;<br/></p>
<p class="paragraph_style_14">ecc_key key;<br/></p>
<p class="paragraph_style_14">// initialize key, make key<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">keySz = wc_ecc_size(&amp;key);<br/></p>
<p class="paragraph_style_14">if ( keySz == 0) {<br/></p>
<p class="paragraph_style_14">// error determining key size<br/></p>
<p class="paragraph_style_14">}<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_9">wc_ecc_make_key<br/></p>
<p class="paragraph_style_9"><br/></p>
<div class="paragraph paragraph_style_9"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_26.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_12"><br/></p>
<p class="paragraph_style_12">wc_ecc_sig_size<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_9">#include &lt;wolfssl/wolfcrypt/ecc.h&gt;<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_9">int wc_ecc_sig_size(ecc_key* key);<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_9">This function returns the worst case size for an ECC signature, given by:<br/></p>
<p class="paragraph_style_9">keySz * 2 + SIG_HEADER_SZ + 4<br/></p>
<p class="paragraph_style_9">The actual signature size can be computed with wc_ecc_sign_hash. <br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_9">Given a valid key, returns the maximum signature <span class="style_3">size</span>, in octets<br/></p>
<p class="paragraph_style_9"><span class="style_3">0</span>: Returned if the given key is NULL<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_9"><span class="style_3">key</span> - pointer to an ecc_key structure for which to get the signature size<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_14">int sigSz;<br/></p>
<p class="paragraph_style_14">ecc_key key;<br/></p>
<p class="paragraph_style_14">// initialize key, make key<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">sigSz = wc_ecc_sig_size(&amp;key);<br/></p>
<p class="paragraph_style_14">if ( sigSz == 0) {<br/></p>
<p class="paragraph_style_14">// error determining sig size<br/></p>
<p class="paragraph_style_14">}<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_9">wc_ecc_sign_hash<br/></p>
<p class="paragraph_style_9"><br/></p>
<div class="paragraph paragraph_style_9"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_27.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_12"><br/></p>
<p class="paragraph_style_12">wc_ecc_ctx_new<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_9">#include &lt;wolfssl/wolfcrypt/ecc.h&gt;<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_9">ecEncCtx* wc_ecc_ctx_new(int flags, RNG* rng);<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_9">This function allocates and initializes space for a new ECC context object to allow secure message exchange with ECC.<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_9">On successfully generating a new ecEncCtx object, returns a <span class="style_3">pointer</span> to that object<br/></p>
<p class="paragraph_style_9"><span class="style_3">NULL</span>: Returned if the function fails to generate a new ecEncCtx object<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_9"><span class="style_3">flags</span> - indicate whether this is a server or client context <br/></p>
<p class="paragraph_style_9">Options are: REQ_RESP_CLIENT, and  REQ_RESP_SERVER<br/></p>
<p class="paragraph_style_9"><span class="style_3">rng</span> - pointer to a RNG object with which to generate a salt<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_14">ecEncCtx* ctx;<br/></p>
<p class="paragraph_style_14">RNG rng;<br/></p>
<p class="paragraph_style_14">wc_InitRng(&amp;rng);<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">ctx = wc_ecc_ctx_new(REQ_RESP_CLIENT, &amp;rng);<br/></p>
<p class="paragraph_style_14">if(ctx == NULL) {<br/></p>
<p class="paragraph_style_14">// error generating new ecEncCtx object<br/></p>
<p class="paragraph_style_14">}<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_9">wc_ecc_encrypt, wc_ecc_decrypt<br/></p>
<p class="paragraph_style_9"><br/></p>
<div class="paragraph paragraph_style_9"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_28.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_12"><br/></p>
<p class="paragraph_style_12">wc_ecc_ctx_free<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_9">#include &lt;wolfssl/wolfcrypt/ecc.h&gt;<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_9">void wc_ecc_ctx_free(ecEncCtx* ctx)<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_9">This function frees the ecEncCtx object used for encrypting and decrypting messages.<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_9">No return values for this function<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_9"><span class="style_3">ctx</span> - pointer to the ecEncCtx object to free<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_14">ecEncCtx* ctx;<br/></p>
<p class="paragraph_style_14">RNG rng;<br/></p>
<p class="paragraph_style_14">wc_InitRng(&amp;rng);<br/></p>
<p class="paragraph_style_14">ctx = wc_ecc_ctx_new(REQ_RESP_CLIENT, &amp;rng);<br/></p>
<p class="paragraph_style_14">// do secure communication<br/></p>
<p class="paragraph_style_14">...<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">wc_ecc_ctx_free(&amp;ctx);<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_9">wc_ecc_ctx_new<br/></p>
<p class="paragraph_style_9"><br/></p>
<div class="paragraph paragraph_style_9"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_29.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_12"><br/></p>
<p class="paragraph_style_12">wc_ecc_ctx_reset<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_9">#include &lt;wolfssl/wolfcrypt/ecc.h&gt;<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_9">int wc_ecc_ctx_reset(ecEncCtx* ctx, RNG* rng);<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_9">This function resets an ecEncCtx structure to avoid having to free and allocate a new context object.<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_9"><span class="style_3">0</span>: Returned if the ecEncCtx structure is successfully reset<br/></p>
<p class="paragraph_style_9"><span class="style_3">BAD_FUNC_ARG</span>: Returned if either rng or ctx is NULL<br/></p>
<p class="paragraph_style_9"><span class="style_3">RNG_FAILURE_E</span>: Returned if there is an error generating a new salt for the ECC object<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_9"><span class="style_3">ctx</span> - pointer to the ecEncCtx object to reset<br/></p>
<p class="paragraph_style_9"><span class="style_3">rng</span> - pointer to an RNG object with which to generate a new salt<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_14">ecEncCtx* ctx;<br/></p>
<p class="paragraph_style_14">RNG rng;<br/></p>
<p class="paragraph_style_14">wc_InitRng(&amp;rng);<br/></p>
<p class="paragraph_style_14">ctx = wc_ecc_ctx_new(REQ_RESP_CLIENT, &amp;rng);<br/></p>
<p class="paragraph_style_14">// do secure communication<br/></p>
<p class="paragraph_style_14">...<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">wc_ecc_ctx_reset(&amp;ctx, &amp;rng);<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">// do more secure communication<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_9">wc_ecc_ctx_new<br/></p>
<p class="paragraph_style_9"><br/></p>
<div class="paragraph paragraph_style_9"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_30.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_12"><br/></p>
<p class="paragraph_style_12">wc_ecc_ctx_get_own_salt<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_9">#include &lt;wolfssl/wolfcrypt/ecc.h&gt;<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_9">const byte* wc_ecc_ctx_get_own_salt(ecEncCtx* ctx);<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_9">This function returns the salt of an ecEncCtx object. This function should only be called when the ecEncCtx's state is ecSRV_INIT or ecCLI_INIT. <br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_9">On success, returns the ecEncCtx <span class="style_3">salt</span><br/></p>
<p class="paragraph_style_9"><span class="style_3">NULL</span>: Returned if the ecEncCtx object is NULL, or the ecEncCtx's state is not ecSRV_INIT or ecCLI_INIT. In the latter two cases, this function also sets the ecEncCtx's state to ecSRV_BAD_STATE or ecCLI_BAD_STATE, respectively<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_9"><span class="style_3">ctx</span> - pointer to the ecEncCtx object from which to get the salt<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_14">ecEncCtx* ctx;<br/></p>
<p class="paragraph_style_14">RNG rng;<br/></p>
<p class="paragraph_style_14">const byte* salt;<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">wc_InitRng(&amp;rng);<br/></p>
<p class="paragraph_style_14">ctx = wc_ecc_ctx_new(REQ_RESP_CLIENT, &amp;rng);<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">salt = wc_ecc_ctx_get_own_salt(&amp;ctx);<br/></p>
<p class="paragraph_style_14">if(salt == NULL) {<br/></p>
<p class="paragraph_style_14">// error getting salt<br/></p>
<p class="paragraph_style_14">}<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_9">wc_ecc_ctx_new, wc_ecc_ctx_set_peer_salt<br/></p>
<p class="paragraph_style_9"><br/></p>
<div class="paragraph paragraph_style_9"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_31.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_12"><br/></p>
<p class="paragraph_style_12">wc_ecc_ctx_set_peer_salt<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_9">#include &lt;wolfssl/wolfcrypt/ecc.h&gt;<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_9">int wc_ecc_ctx_set_peer_salt(ecEncCtx* ctx, const byte* salt);<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_9">This function sets the peer salt of an ecEncCtx object. <br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_9"><span class="style_3">0</span>: Returned upon successfully setting the peer salt for the ecEncCtx object.<br/></p>
<p class="paragraph_style_9"><span class="style_3">BAD_FUNC_ARG</span>: Returned if the given ecEncCtx object is NULL or has an invalid protocol, or if the given salt is NULL<br/></p>
<p class="paragraph_style_9"><span class="style_3">BAD_ENC_STATE_E</span>: Returned if the ecEncCtx's state is ecSRV_SALT_GET or ecCLI_SALT_GET. In the latter two cases, this function also sets the ecEncCtx's state to ecSRV_BAD_STATE or ecCLI_BAD_STATE, respectively<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_9"><span class="style_3">ctx</span> - pointer to the ecEncCtx for which to set the salt<br/></p>
<p class="paragraph_style_9"><span class="style_3">salt</span> - pointer to the peer's salt<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_14">ecEncCtx* cliCtx, srvCtx;<br/></p>
<p class="paragraph_style_14">RNG rng;<br/></p>
<p class="paragraph_style_14">const byte* cliSalt, srvSalt;<br/></p>
<p class="paragraph_style_14">int ret;<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">wc_InitRng(&amp;rng);<br/></p>
<p class="paragraph_style_14">cliCtx = wc_ecc_ctx_new(REQ_RESP_CLIENT, &amp;rng);<br/></p>
<p class="paragraph_style_14">srvCtx = wc_ecc_ctx_new(REQ_RESP_SERVER, &amp;rng);<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">cliSalt = wc_ecc_ctx_get_own_salt(&amp;cliCtx);<br/></p>
<p class="paragraph_style_14">srvSalt = wc_ecc_ctx_get_own_salt(&amp;srvCtx);<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">ret = wc_ecc_ctx_set_peer_salt(&amp;cliCtx, srvSalt);<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_9">wc_ecc_ctx_get_own_salt<br/></p>
<p class="paragraph_style_9"><br/></p>
<div class="paragraph paragraph_style_9"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_32.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_12"><br/></p>
<p class="paragraph_style_12">wc_ecc_ctx_set_info<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_9">#include &lt;wolfssl/wolfcrypt/ecc.h&gt;<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_9">int wc_ecc_ctx_set_info(ecEncCtx* ctx, const byte* info, int sz);<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_9">This function can optionally be called before or after wc_ecc_ctx_set_peer_salt. It sets optional information for an ecEncCtx object.<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_9"><span class="style_3">0</span>: Returned upon successfully setting the information for the ecEncCtx object.<br/></p>
<p class="paragraph_style_9"><span class="style_3">BAD_FUNC_ARG</span>: Returned if the given ecEncCtx object is NULL, the input info is NULL or it's size is invalid<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_9"><span class="style_3">ctx</span> - pointer to the ecEncCtx for which to set the info<br/></p>
<p class="paragraph_style_9"><span class="style_3">info</span> - pointer to a buffer containing the info to set<br/></p>
<p class="paragraph_style_9"><span class="style_3">sz</span> - size of the info buffer<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_14">ecEncCtx* ctx;<br/></p>
<p class="paragraph_style_14">byte info[] = { /* initialize with information */ };<br/></p>
<p class="paragraph_style_14">// initialize ctx, get salt,<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">if(wc_ecc_ctx_set_info(&amp;ctx, info, sizeof(info))) {<br/></p>
<p class="paragraph_style_14">// error setting info<br/></p>
<p class="paragraph_style_14">}<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_9">wc_ecc_ctx_new<br/></p>
<p class="paragraph_style_9"><br/></p>
<div class="paragraph paragraph_style_9"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_33.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_12"><br/></p>
<p class="paragraph_style_12">wc_ecc_encrypt<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_9">#include &lt;wolfssl/wolfcrypt/ecc.h&gt;<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_9">int wc_ecc_encrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg, word32 msgSz, <br/></p>
<p class="paragraph_style_9">byte* out, word32* outSz, ecEncCtx* ctx);<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_9">This function encrypts the given input message from msg to out. This function takes an optional ctx object as parameter. When supplied, encryption proceeds based on the ecEncCtx's encAlgo, kdfAlgo, and macAlgo. If ctx is not supplied, processing completes with the default algorithms, ecAES_128_CBC, ecHKDF_SHA256 and ecHMAC_SHA256.<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_9">This function requires that the messages are padded according to the encryption type specified by ctx. <br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_9"><span class="style_3">0</span>: Returned upon successfully encrypting the input message<br/></p>
<p class="paragraph_style_9"><span class="style_3">BAD_FUNC_ARG</span>: Returned if privKey, pubKey, msg, msgSz, out, or outSz are NULL, or the ctx object specifies an unsupported encryption type<br/></p>
<p class="paragraph_style_9"><span class="style_3">BAD_ENC_STATE_E</span>: Returned if the ctx object given is in a state that is not appropriate for encryption<br/></p>
<p class="paragraph_style_9"><span class="style_3">BUFFER_E</span>: Returned if the supplied output buffer is too small to store the encrypted ciphertext<br/></p>
<p class="paragraph_style_9"><span class="style_3">MEMORY_E</span>: Returned if there is an error allocating memory for the shared secret key<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_9"><span class="style_3">privKey</span> - pointer to the ecc_key object containing the private key to use for encryption<br/></p>
<p class="paragraph_style_9"><span class="style_3">pubKey</span> - pointer to the ecc_key object containing the public key of the peer with whom one wishes to communicate<br/></p>
<p class="paragraph_style_9"><span class="style_3">msg</span>- pointer to the buffer holding the message to encrypt<br/></p>
<p class="paragraph_style_9"><span class="style_3">msgSz</span> - size of the buffer to encrypt<br/></p>
<p class="paragraph_style_9"><span class="style_3">out</span> - pointer to the buffer in which to store the encrypted ciphertext <br/></p>
<p class="paragraph_style_9"><span class="style_3">outSz</span> - pointer to a word32 object containing the available size in the out buffer. Upon successfully encrypting the message, holds the number of bytes written to the output buffer<br/></p>
<p class="paragraph_style_9"><span class="style_3">ctx</span> - Optional: pointer to an ecEncCtx object specifying different encryption algorithms to use<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_14">byte msg[] = { /* initialize with msg to encrypt. Ensure padded to block size */ };<br/></p>
<p class="paragraph_style_14">byte out[sizeof(msg)];<br/></p>
<p class="paragraph_style_14">word32 outSz = sizeof(out);<br/></p>
<p class="paragraph_style_14">int ret;<br/></p>
<p class="paragraph_style_14">ecc_key cli, serv;<br/></p>
<p class="paragraph_style_14">// initialize cli with private key<br/></p>
<p class="paragraph_style_14">// initialize serv with received public key<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">ecEncCtx* cliCtx, servCtx;<br/></p>
<p class="paragraph_style_14">// initialize cliCtx and servCtx<br/></p>
<p class="paragraph_style_14">// exchange salts<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">ret = wc_ecc_encrypt(&amp;cli, &amp;serv, msg, sizeof(msg), out, &amp;outSz, cliCtx);<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">if(ret != 0) { <br/></p>
<p class="paragraph_style_14">// error encrypting message <br/></p>
<p class="paragraph_style_14">}<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_9">wc_ecc_decrypt<br/></p>
<p class="paragraph_style_9"><br/></p>
<div class="paragraph paragraph_style_9"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_34.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_12"><br/></p>
<p class="paragraph_style_12">wc_ecc_decrypt<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Synopsis:<br/></p>
<p class="paragraph_style_9">#include &lt;wolfssl/wolfcrypt/ecc.h&gt;<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_9">int wc_ecc_decrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg, word32 msgSz, <br/></p>
<p class="paragraph_style_9">byte* out, word32* outSz, ecEncCtx* ctx);<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Description:<br/></p>
<p class="paragraph_style_9">This function decrypts the ciphertext from msg to out. This function takes an optional ctx object as parameter. When supplied, encryption proceeds based on the ecEncCtx's encAlgo, kdfAlgo, and macAlgo. If ctx is not supplied, processing completes with the default algorithms, ecAES_128_CBC, ecHKDF_SHA256 and ecHMAC_SHA256.<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_9">This function requires that the messages are padded according to the encryption type specified by ctx. <br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Return Values:<br/></p>
<p class="paragraph_style_9"><span class="style_3">0</span>: Returned upon successfully decrypting the input message<br/></p>
<p class="paragraph_style_9"><span class="style_3">BAD_FUNC_ARG</span>: Returned if privKey, pubKey, msg, msgSz, out, or outSz are NULL, or the ctx object specifies an unsupported encryption type<br/></p>
<p class="paragraph_style_9"><span class="style_3">BAD_ENC_STATE_E</span>: Returned if the ctx object given is in a state that is not appropriate for decryption<br/></p>
<p class="paragraph_style_9"><span class="style_3">BUFFER_E</span>: Returned if the supplied output buffer is too small to store the decrypted plaintext<br/></p>
<p class="paragraph_style_9"><span class="style_3">MEMORY_E</span>: Returned if there is an error allocating memory for the shared secret key<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Parameters:<br/></p>
<p class="paragraph_style_9"><span class="style_3">privKey</span> - pointer to the ecc_key object containing the private key to use for decryption<br/></p>
<p class="paragraph_style_9"><span class="style_3">pubKey</span> - pointer to the ecc_key object containing the public key of the peer with whom one wishes to communicate<br/></p>
<p class="paragraph_style_9"><span class="style_3">msg</span>- pointer to the buffer holding the ciphertext to decrypt<br/></p>
<p class="paragraph_style_9"><span class="style_3">msgSz</span> - size of the buffer to decrypt<br/></p>
<p class="paragraph_style_9"><span class="style_3">out</span> - pointer to the buffer in which to store the decrypted plaintext<br/></p>
<p class="paragraph_style_9"><span class="style_3">outSz</span> - pointer to a word32 object containing the available size in the out buffer. Upon successfully decrypting the ciphertext, holds the number of bytes written to the output buffer<br/></p>
<p class="paragraph_style_9"><span class="style_3">ctx</span> - Optional: pointer to an ecEncCtx object specifying different decryption algorithms to use<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">Example:<br/></p>
<p class="paragraph_style_14">byte cipher[] = { /* initialize with ciphertext to decrypt. Ensure padded to block size */ };<br/></p>
<p class="paragraph_style_14">byte plain[sizeof(cipher)];<br/></p>
<p class="paragraph_style_14">word32 plainSz = sizeof(plain);<br/></p>
<p class="paragraph_style_14">int ret;<br/></p>
<p class="paragraph_style_14">ecc_key cli, serv;<br/></p>
<p class="paragraph_style_14">// initialize cli with private key<br/></p>
<p class="paragraph_style_14">// initialize serv with received public key<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">ecEncCtx* cliCtx, servCtx;<br/></p>
<p class="paragraph_style_14">// initialize cliCtx and servCtx<br/></p>
<p class="paragraph_style_14">// exchange salts<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">ret = wc_ecc_decrypt(&amp;cli, &amp;serv, cipher, sizeof(cipher), plain, &amp;plainSz, cliCtx);<br/></p>
<p class="paragraph_style_14"><br/></p>
<p class="paragraph_style_14">if(ret != 0) { <br/></p>
<p class="paragraph_style_14">// error decrypting message <br/></p>
<p class="paragraph_style_14">}<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_13">See Also:<br/></p>
<p class="paragraph_style_9">wc_ecc_encrypt<br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_35.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
</div>
<div style="clear: both; height: 0px; line-height: 0px; " class="tinyText"> </div>
</div>
</div>
<div style="height: 16px; width: 20px;  height: 16px; left: 706px; position: absolute; top: 51px; width: 20px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 20px; ">
<img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/shapeimage_36.png" alt="" style="height: 16px; left: 0px; position: absolute; top: 0px; width: 20px; "/>
</div>
</div>
<div style="height: 19px; width: 19px;  height: 19px; left: 707px; position: absolute; top: 25px; width: 19px; z-index: 1; " class="tinyText style_SkipStroke_2">
<img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/United%20Kingdom(Great%20Britain).png" alt="" style="border: none; height: 19px; width: 19px; "/>
</div>
<div id="id16" style="height: 23px; left: 328px; position: absolute; top: 48px; width: 258px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_258_23" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_16">Questions? +1 (425) 245-8247</p>
</div>
</div>
</div>
<div style="height: 19px; width: 19px;  height: 19px; left: 685px; position: absolute; top: 25px; width: 19px; z-index: 1; " class="tinyText style_SkipStroke_2">
<a href="http://www.wolfssl.jp/" title="http://www.wolfssl.jp"><img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/japan.png" alt="" style="border: none; height: 19px; width: 19px; "/></a>
</div>
<div id="id17" style="height: 28px; left: 593px; position: absolute; top: 44px; width: 119px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_119_28" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_17"><a class="class13" title="https://www.wolfssl.com/forums" href="https://www.wolfssl.com/forums">Support <span class="style_4">Forums</span></a></p>
</div>
</div>
</div>
<div id="id18" style="height: 27px; left: 59px; position: absolute; top: 190px; width: 342px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_342_27" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_18"><a class="class14" title="https://www.wolfssl.com/documentation/wolfSSL-Manual.pdf" href="https://www.wolfssl.com/documentation/wolfSSL-Manual.pdf">Download wolfSSL Manual (PDF)</a></p>
</div>
</div>
</div>
<div style="height: 121px; width: 155px;  height: 121px; left: 32px; position: absolute; top: 5px; width: 155px; z-index: 1; " class="tinyText style_SkipStroke_2">
<a href="Home.html" title="Home.html"><img src="Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc_files/wolfssl_logo.png" alt="" style="border: none; height: 121px; width: 156px; "/></a>
</div>
<div style="height: 14332px; line-height: 14332px; " class="spacer"> </div>
</div>
<div style="height: 114px; margin-left: 0px; position: relative; width: 770px; z-index: 15; " id="footer_layer">
<div style="height: 0px; line-height: 0px; " class="bumper"> </div>
<div id="id19" style="height: 27px; left: 634px; position: absolute; top: 47px; width: 102px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_102_27" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_4"><a class="class15" title="Docs-wolfssl-manual-18-15-wolfcrypt-api-ed25519.html" href="Docs-wolfssl-manual-18-15-wolfcrypt-api-ed25519.html">Next Chapter</a></p>
</div>
</div>
</div>
<div id="id20" style="height: 25px; left: 35px; position: absolute; top: 47px; width: 125px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_125_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_19"><a class="class16" title="Docs-wolfssl-manual-18-13-wolfcrypt-api-dsa.html" href="Docs-wolfssl-manual-18-13-wolfcrypt-api-dsa.html">Previous Chapter</a></p>
</div>
</div>
</div>
<div id="id21" style="height: 25px; left: 323px; position: absolute; top: 47px; width: 125px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_125_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_6"><a class="class17" title="Docs-wolfssl-manual-toc.html" href="Docs-wolfssl-manual-toc.html">Table of Contents</a></p>
</div>
</div>
</div>
<div id="id22" style="height: 29px; left: 35px; position: absolute; top: 85px; width: 701px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_701_29" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_20">Copyright 2017 wolfSSL Inc.  All rights reserved.</p>
</div>
</div>
</div>
</div>
</div>
</div>
 </body>

<!-- Mirrored from www.wolfssl.com/wolfSSL/Docs-wolfssl-manual-18-14-wolfcrypt-api-ecc.html by HTTrack Website Copier/3.x [XR&CO'2014], Tue, 17 Jan 2017 13:40:52 GMT -->
</html>
